package com.leetcode.August;

import java.util.Locale;

/**
 * @Description: 125验证回文串
 * @Author: Mr.Fxy
 * @CreateTime: 2024-08-22 16:00
 */
public class LC125验证回文串 {
    public boolean isPalindrome(String s) {
        String cleaned = s.toLowerCase().replaceAll("[^a-z0-9]", "");
        int left = 0, right = cleaned.length() - 1;
        while (left < right){
            if (cleaned.charAt(left)!=cleaned.charAt(right)){
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}
